﻿#region File Header
//-----------------------------------------------------------------------------
// Bricks' Bane Editor
//
// Copyright (C) 2010 Julien Villers
// This program is distributed under the terms of the 
// GNU Lesser General Public License (LGPL).
// See Docs/lgpl.txt and Docs/gpl.txt
//-----------------------------------------------------------------------------
#endregion

using System.Collections.Generic;
using System.Drawing;

namespace BricksBaneEditor
{
    class Brick
    {
        Point m_Position;
        Size m_Size;
        Color m_Color;
        E_Types m_Type;

        public enum E_Types
        {
            Basic = 0,
            Multiple,
            Unbreakable,
            Nitro,
        };

        public Point Position
        {
            get { return m_Position; }
            set { m_Position = value; }
        }

        public Size Size
        {
            get { return m_Size; }
            set { m_Size = value; }
        }

        public Rectangle Rect
        {
            get { return new Rectangle(m_Position, m_Size); }
        }

        public Color Color
        {
            get { return m_Color; }
            set { m_Color = value; }
        }

        public E_Types Type
        {
            get { return m_Type; }
            set { m_Type = value; }
        }
    };

    class Wall
    {
        public Size BrickSize
        {
            get { return new Size(48, 24); }            // TODO: properly handle sizes (if needed).
        }

        public List<Brick> Bricks
        {
            get;
            private set;
        }

        public Wall()
        {
            Bricks = new List<Brick>(256);
        }

        public Brick FindBrickAt(Point position)
        {
            Size size = new Size(position);
            foreach (Brick brick in Bricks)
            {
                Point delta = brick.Position - size;
                if (delta.X <= 0 && delta.X > -brick.Size.Width &&
                    delta.Y <= 0 && delta.Y > -brick.Size.Height)
                    return brick;
            }

            return null;
        }
    }
}
